Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/android buildtime bug #1708

Closed
wants to merge 7 commits into from
Closed

Conversation

bartekpacia
Copy link
Contributor

@bartekpacia bartekpacia commented Sep 18, 2023

Fixes problem with META-INF being malformed or something:

Details
FAILURE: Build failed with an exception.

	* What went wrong:
	Execution failed for task ':app:mergeTstDebugJavaResource'.
	> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
	   > 8 files found with path 'META-INF/INDEX.LIST' from inputs:
	      - /Users/bartek/.gradle/caches/transforms-3/98ae5c88d5d9e3a49e85ceeadaccd680/transformed/jetified-netty-codec-http2-4.1.97.Final.jar
	      - /Users/bartek/.gradle/caches/transforms-3/585598deb7118dd86a2c91b7b3075b31/transformed/jetified-netty-codec-http-4.1.97.Final.jar
	      - /Users/bartek/.gradle/caches/transforms-3/d3358bfd0e025c85a6f891b9ed3f2f31/transformed/jetified-netty-handler-4.1.97.Final.jar
	      - /Users/bartek/.gradle/caches/transforms-3/6e8f68de7d2406c67c44dcef25255c78/transformed/jetified-netty-codec-4.1.97.Final.jar
	      - /Users/bartek/.gradle/caches/transforms-3/a261241c75df2e8a68b904aac3b66a6d/transformed/jetified-netty-transport-native-unix-common-4.1.97.Final.jar
	      - /Users/bartek/.gradle/caches/transforms-3/e845d3b30e38824ff09a8cacda9eb4d0/transformed/jetified-netty-transport-4.1.97.Final.jar
	      - /Users/bartek/.gradle/caches/transforms-3/fbe9ace71e46599ec1d465186846083e/transformed/jetified-netty-buffer-4.1.97.Final.jar
	      - /Users/bartek/.gradle/caches/transforms-3/75dbc5850a0808ffbf1a6160a82855c2/transformed/jetified-netty-resolver-4.1.97.Final.jar
	     Adding a packagingOptions block may help, please refer to
	     https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/ResourcesPackagingOptions
	     for more information

	* Try:
	> Run with --stacktrace option to get the stack trace.
	> Run with --info or --debug option to get more log output.
	> Run with --scan to get full insights.

	* Get more help at https://help.gradle.org/

@bartekpacia bartekpacia requested a review from zltnDC September 18, 2023 08:12
@github-actions github-actions bot added package: patrol Related to the patrol package (native automation, test bundling) package: patrol_cli Related to the patrol_cli package labels Sep 18, 2023
@bartekpacia bartekpacia changed the base branch from master to develop September 18, 2023 08:13
@github-actions github-actions bot removed the package: patrol_cli Related to the patrol_cli package label Sep 18, 2023
@bartekpacia bartekpacia marked this pull request as draft September 18, 2023 08:35
@bartekpacia bartekpacia force-pushed the fix/android_buildtime_bug branch from dc91829 to ce54fac Compare September 18, 2023 09:01
@bartekpacia
Copy link
Contributor Author

OkHttp is over-reacting to network security policy.

We are making unencrypted HTTP connections, but within a single process. It was always working, but now OkHttp isn't happy with it.

Crash logs
09-18 10:53:56.866  7532  7551 I TestRunner: run started: 1 tests
09-18 10:53:56.867  7532  7551 I TestRunner: started: initializationError(pl.leancode.patrol.example.MainActivityTest)
09-18 10:53:56.867  7532  7551 E TestRunner: failed: initializationError(pl.leancode.patrol.example.MainActivityTest)
09-18 10:53:56.867  7532  7551 E TestRunner: ----- begin exception -----
09-18 10:53:56.869  7532  7551 E TestRunner: java.net.UnknownServiceException: CLEARTEXT communication to localhost not permitted by network security policy
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:188)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.http4k.client.OkHttp$invoke$1.invoke(OkHttp.kt:39)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.http4k.client.OkHttp$invoke$1.invoke(OkHttp.kt:36)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at pl.leancode.patrol.contracts.PatrolAppServiceClient.performRequest(PatrolAppServiceClient.kt:44)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at pl.leancode.patrol.contracts.PatrolAppServiceClient.performRequest$default(PatrolAppServiceClient.kt:30)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at pl.leancode.patrol.contracts.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:21)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at pl.leancode.patrol.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:32)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at pl.leancode.patrol.PatrolJUnitRunner.listDartTests(PatrolJUnitRunner.java:114)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at pl.leancode.patrol.example.MainActivityTest.testCases(MainActivityTest.java:17)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at java.lang.reflect.Method.invoke(Native Method)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.runners.Parameterized$RunnersFactory.allParameters(Parameterized.java:424)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.runners.Parameterized$RunnersFactory.<init>(Parameterized.java:375)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.runners.Parameterized$RunnersFactory.<init>(Parameterized.java:360)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.runners.Parameterized.<init>(Parameterized.java:303)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at java.lang.reflect.Constructor.newInstance0(Native Method)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at androidx.test.internal.runner.junit4.AndroidAnnotatedBuilder.runnerForClass(AndroidAnnotatedBuilder.java:63)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at androidx.test.internal.runner.AndroidRunnerBuilder.runnerForClass(AndroidRunnerBuilder.java:149)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at androidx.test.internal.runner.AndroidLogOnlyBuilder.runnerForClass(AndroidLogOnlyBuilder.java:93)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at androidx.test.internal.runner.ScanningTestLoader.doCreateRunner(ScanningTestLoader.java:50)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at androidx.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:64)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at androidx.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:835)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at androidx.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:650)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:418)
09-18 10:53:56.869  7532  7551 E TestRunner: 	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2361)
09-18 10:53:56.869  7532  7551 E TestRunner: ----- end exception -----
09-18 10:53:56.871  7532  7551 I TestRunner: finished: initializationError(pl.leancode.patrol.example.MainActivityTest)
09-18 10:53:56.871  7532  7551 D TestDiscoveryListener: JUnit reported pl.leancode.patrol.example.MainActivityTest#initializationError; discarding as bogus.

@bartekpacia bartekpacia mentioned this pull request Sep 18, 2023
@bartekpacia
Copy link
Contributor Author

bartekpacia commented Sep 18, 2023

  • OkHttp over-reacts to network security policy. See comment above.
  • Android's native UrlHTTPConnection - crashes with the same error as OkHttp, because it actually is OkHttp. Source.
  • Fuel - crashes with same, probably because uses UrlHTTPConnection, which is OkHttp under the hood
  • Ktor client - requires coroutines, not so easy to bridge with Java code that makes requests
  • JavaHttpClient is not available on Android

@bartekpacia
Copy link
Contributor Author

Superseded by #1711

@bartekpacia bartekpacia deleted the fix/android_buildtime_bug branch September 18, 2023 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: patrol Related to the patrol package (native automation, test bundling)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant